<template>
	<view style="height: 100%;background: #FFFFFF;">
		<view style="display: flex;flex-wrap: wrap;height: 100%;">
			<image class="bg" src="http://img.curiousmore.com/tmp/wx2f4eaeb7b745ba4e.o6zAJs2bel8UMMafp-gtnT7OfHzo.MbnTEnikWqPN47b36d29885799816e6230755e5a108f.png" mode=""></image>
			<view class="Lecturer-card" v-for="(item,index) in Setlecturer" :key="index">
				<view style="font-weight: bold;font-size: 32upx;">
					<text>直播课堂讲师</text>
				</view>
				<view>
					<text>课堂数量:{{item.map.groupClassCount}}</text>
				</view>
				<view>
					<text>暂无课程</text>
				</view>
				<view>
					<text>累计收益</text>
					<text style="color: #FF6100;">{{item.popularity}}元</text>
					<text>本月收益</text>
					<text style="color: #FF6100;">{{item.price}}元</text>
				</view>
				<view>
					<text>累计课时</text>
					<text>{{item.map.courseCount}}节</text>
					<text >本月课时</text>
					<text style="color: #FF6100;">{{item.map.classCount}}节</text>
					<text>剩余课节</text>
					<text>{{item.map.currentStudentCount}}节</text>
				</view>
				
				<view style="text-align: center;">
					<text>入驻时间:{{item.create_time}}</text>
				</view>
			</view>
			<view class="curriculum">
				<view class="curriculum-title">
					<text v-for="(item,index) in curriculumMeau" :class="{activeNav : curriculumMeauindex == index}" :key="index" @tap="Switchtitle(index)">{{item}}</text>
				</view>
				<scroll-view v-if="curriculumMeauindex == 0" class="Detial-meauinfo" scroll-y="true">
					<view>
						<view id="panel" class="flex-column">
							<view class="flex-cell flex-row">
								<text class="flex-cell flex-row">{{Thecurrentmonth}}</text>
								<text class="flex-cell flex-row" style="height: 5vh;flex: 1.5;flex-wrap: wrap;line-height: 5vh;">第四周</text>
								<text class="flex-cell flex-row" style="height: 5vh;flex: 1.5;flex-wrap: wrap;line-height: 5vh;">课节</text>
							</view>
							<view class="flex-row flex-cell">
								<text class="flex-cell flex-row">周一{{WeekDay1}}</text>
								<text class="flex-cell flex-row"></text>
								<text class="flex-cell flex-row"></text>
								<text class="flex-cell flex-row"></text>
							</view>
							<view class="flex-row flex-cell">
								<text class="flex-cell flex-row">周二{{WeekDay2}}</text>
								<text class="flex-cell flex-row"></text>
								<text class="flex-cell flex-row"></text>
								<text class="flex-cell flex-row"></text>
							</view>
							<view class="flex-row flex-cell">
								<text class="flex-cell flex-row">周三{{WeekDay3}}</text>
								<text class="flex-cell flex-row"></text>
								<text class="flex-cell flex-row"></text>
								<text class="flex-cell flex-row"></text>
							</view>
							<view class="flex-row flex-cell">
								<text class="flex-cell flex-row">周四{{WeekDay4}}</text>
								<text class="flex-cell flex-row"></text>
								<text class="flex-cell flex-row"></text>
								<text class="flex-cell flex-row"></text>
							</view>	
							<view class="flex-row flex-cell">
								<text class="flex-cell flex-row">周五{{WeekDay5}}</text>
								<text class="flex-cell flex-row"></text>
								<text class="flex-cell flex-row"></text>
								<text class="flex-cell flex-row"></text>
							</view>
							<view class="flex-row flex-cell">
								<text class="flex-cell flex-row">周六{{WeekDay6}}</text>
								<text class="flex-cell flex-row"></text>
								<text class="flex-cell flex-row"></text>
								<text class="flex-cell flex-row"></text>
							</view>
							<view class="flex-row flex-cell">
								<text class="flex-cell flex-row">周日{{WeekDay7}}</text>
								<text class="flex-cell flex-row"></text>
								<text class="flex-cell flex-row"></text>
								<text class="flex-cell flex-row"></text>
							</view>
						</view>	
					</view>
				</scroll-view>
				<scroll-view v-if="curriculumMeauindex == 1" class="Detial-meauinfo" scroll-y="true">
					<view>
						<view class="Classlist" v-for="(item,index) in getclasslist" :key="index">
							<image :src="item.faceUrl" class="Class_avter"></image>
							<view class="Class_title">
								<view class="Class_infochild">{{item.group_name}}</view>
								<view class="Class_infochild">{{item.label}}</view>
								<view class="Class_infochild">{{item.language}}</view>
							</view>
							<view class="Class_details">
								<image src="../../../static/jingyu/yuyin.png" class="Class_detailschild"></image>
								<view class="Class_detailschild">视频直播课堂</view>
								<view class="Class_detailschild">直播中</view>
								<view class="Class_detailschild">{{item.online_num}}人参与</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
			<!--底部按钮 -->
			<view class="FootButoon">
				<view @tap="ToChat">畅聊</view>
				<view @tap="FocusOn" v-if="IsFlow">取消关注</view>
				<view @tap="FocusOn" v-else>关注</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				curriculumMeau:['课程表','班级'],//标题数组
				curriculumMeauindex:'0',//标题下标
				getclasslist:[],
				ClassName:'',
				ClassId:'',
				ownerid:'',
				Setlecturer:[],//直播讲师内容
				IsFlow:'',
				Thecurrentmonth:'',//当前日月
				WeekDay1:'',
				WeekDay2:'',
				WeekDay3:'',
				WeekDay4:'',
				WeekDay5:'',
				WeekDay6:'',
				WeekDay7:'',
				queryScheduleList:[],
			}
		},
		onLoad(e) {
			this.ownerid = e.user_id
			this.Switchtitle(e==1)
			this.Getlecturer()
			this.IsFlollow()	
		},
		methods: {
			Switchtitle(e){
				let _this = this
				_this.curriculumMeauindex = e
				if(_this.curriculumMeauindex == 1){
					_this.getclasslist = []
					var data = {
						owner_id:_this.ownerid,
					}
					_this.myAjaxNew({//获取我的班级列表
						model: 'message',
						controllerName: 'messageGroup',
						actionName: 'queryMyListPage',
						data: data,
						successBack: function(res) {
							_this.getclasslist = _this.getclasslist.concat(res.data.data)
						},
					})
				}else if(_this.curriculumMeauindex == 0){
					_this.getclasslist = []
					var date = new Date();
					let Y = date.getFullYear()
					let M = date.getMonth() + 1
					let D = date.getDate()
					let W = date.getDay(); 
					let T = date.toLocaleTimeString();
					
					_this.Thecurrentmonth = Y+'-'+M
					if(W == 0){//星期天
						let Ds = D-6
						_this.WeekDay1 = M+'-'+Ds
						_this.WeekDay2 = M+'-'+(Ds-5)
						_this.WeekDay3 = M+'-'+(Ds-4)
						_this.WeekDay4 = M+'-'+(Ds-3)
						_this.WeekDay5 = M+'-'+(Ds-2)
						_this.WeekDay6 = M+'-'+(Ds-1)
						_this.WeekDay7 = M+'-'+D
					}else if(W == 1){//星期一
						_this.WeekDay1 = M+'-'+D
						_this.WeekDay2 = M+'-'+(D+1)
						_this.WeekDay3 = M+'-'+(D+2)
						_this.WeekDay4 = M+'-'+(D+3)
						_this.WeekDay5 = M+'-'+(D+4)
						_this.WeekDay6 = M+'-'+(D+5)
						_this.WeekDay7 = M+'-'+(D+6)
					}else if(W == 2){//星期二
						_this.WeekDay1 = M+'-'+(D-1)
						_this.WeekDay2 = M+'-'+(D)
						_this.WeekDay3 = M+'-'+(D+1)
						_this.WeekDay4 = M+'-'+(D+2)
						_this.WeekDay5 = M+'-'+(D+3)
						_this.WeekDay6 = M+'-'+(D+4)
						_this.WeekDay7 = M+'-'+(D+5)
					}else if(W == 3){//星期三
						_this.WeekDay1 = M+'-'+(D-2)
						_this.WeekDay2 = M+'-'+(D-1)
						_this.WeekDay3 = M+'-'+(D)
						_this.WeekDay4 = M+'-'+(D+1)
						_this.WeekDay5 = M+'-'+(D+2)
						_this.WeekDay6 = M+'-'+(D+3)
						_this.WeekDay7 = M+'-'+(D+4)
					}else if(W == 4){//星期四
						_this.WeekDay1 = M+'-'+(D-3)
						_this.WeekDay2 = M+'-'+(D-2)
						_this.WeekDay3 = M+'-'+(D-1)
						_this.WeekDay4 = M+'-'+(D)
						_this.WeekDay5 = M+'-'+(D+1)
						_this.WeekDay6 = M+'-'+(D+2)
						_this.WeekDay7 = M+'-'+(D+3)
					}else if(W == 5){//星期五
						_this.WeekDay1 = M+'-'+(D-4)
						_this.WeekDay2 = M+'-'+(D-3)
						_this.WeekDay3 = M+'-'+(D-2)
						_this.WeekDay4 = M+'-'+(D-1)
						_this.WeekDay5 = M+'-'+(D)
						_this.WeekDay6 = M+'-'+(D+1)
						_this.WeekDay7 = M+'-'+(D+2)
					}else if(W == 6){//星期六
						_this.WeekDay1 = M+'-'+(D-5)
						_this.WeekDay2 = M+'-'+(D-4)
						_this.WeekDay3 = M+'-'+(D-3)
						_this.WeekDay4 = M+'-'+(D-2)
						_this.WeekDay5 = M+'-'+(D-1)
						_this.WeekDay6 = M+'-'+(D)
						_this.WeekDay7 = M+'-'+(D+1)
					}
					let start_time =Y +'-'+ _this.WeekDay1+' '+'00:00:00'
					let end_time = Y +'-'+ _this.WeekDay7+' '+'00:00:00'
					var data = {
						master_id:_this.ownerid,
						type:'open_class',
						start_time:start_time,
						end_time:end_time,
						offset:'0'
					}
					_this.myAjaxNew({//获取我的班级列表
						model: 'user',
						controllerName: 'masterAppointment',
						actionName: 'querySchedule',
						data: data,
						successBack: function(res) {
							_this.queryScheduleList =res.data.data
							console.info(res,'我的课程')
						},
					})
				}
			},
			Getlecturer(){//获取直播讲师内容
				let _this = this
				let data = {
					user_id:_this.ownerid,
					type:"live_lecturer"
				}
				_this.myAjaxNew({
					model: 'user',
					controllerName: 'masterInfo',
					actionName: 'queryTeachingCenter',
					data: data,
					successBack:function(res){
						_this.Setlecturer = _this.Setlecturer.concat(res.data.data)
					}
				})
			},
			IsFlollow(){//查询是否关注主播
				let _this = this
				let data ={
					user_id:uni.getStorageSync('user_id'),
					master_id:_this.ownerid
				}
				_this.myAjaxNew({
					model: 'user',
					controllerName: 'masterFollow',
					actionName: 'queryIsFollow',
					data: data,
					successBack:function(res){
						_this.IsFlow = res.data.data.is_follow
						console.info(res,'你好啊')
					}
				})
			},
			ToChat(){//去聊天页面
				uni.navigateTo({
					url:'/pages/Friend/chat/chat?item='+this.ownerid+'&item=9191&chatType=C2C&MsgSeq=9844373'
				})
			},
			FocusOn(){//关注和取消
				let _this = this
				if(_this.IsFlow){//取消关注
					let data ={
						user_id:uni.getStorageSync('user_id'),
						master_id:_this.ownerid
					}
					_this.myAjaxNew({
						model: 'user',
						controllerName: 'masterFollow',
						actionName: 'deleteFollow',
						data: data,
						successBack:function(res){
							_this.IsFlow = false
						}
					})
				}else{//关注
					let data ={
						user_id:uni.getStorageSync('user_id'),
						master_id:_this.ownerid
					}
					_this.myAjaxNewPost({
						model: 'user',
						controllerName: 'masterFollow',
						actionName: 'insert',
						data: data,
						successBack:function(res){
							console.info(res,'你好啊222')
							_this.IsFlow = true
						}
					})
				}
				
			}
		}
	}
</script>

<style scoped lang="less">
	.bg {
		height: 410upx;
		width: 100%;
		position: fixed;
		top: 0upx;
	}
	/*讲师名片样式*/
	.Lecturer-card{
		display: flex;
		width: 90%;
		height: 520upx;
		background: #FFFFFF;
		border-radius: 16upx;
		z-index: 100;
		margin: 0 auto;
		margin-top: 100upx;
		flex-wrap: wrap;
		justify-content: center;
		flex-direction: column;
		box-shadow: 2px 2px 3px 2px rgba(0,0,0,0.5), -1px 1px 1px 1px rgba(0,0,0,0.5);	
		view{
			width: 100%;
			height: 80upx;
			font-size: 26upx;	
			justify-content: center;
			align-items: center; 
			text{
				height: 80upx;
				padding-left: 20upx;
			}
		}
	}
	/*课程表导航样式*/
	.curriculum{
		display: flex;
		width: 100%;
		height: 50%;
		overflow: hidden;
		flex-wrap: wrap;
		background: #FFFFFF;
	}
	.curriculum-title{
		display: flex;
		width: 100%;
		height: 16%;
		flex-wrap: wrap;
		align-content: flex-center;
		align-items: center;
		justify-content: space-around;
		text{
			display: flex;
			flex: 1;
			height: 120upx;
			align-items: center;
			justify-content: center;
		}
	}
	.activeNav{/*tabs点击后的样式*/
		color: #00BCBB;
		border-bottom: 3upx solid #00BCBB;
	}
	.Detial-meauinfo{
		position: relative;
		width: 100%;
		height: 74%;
		margin-top: 40upx;
		overflow: hidden;
		font-size: 26upx;
	}
	
	.Classlist{
		display: flex;
		height: 130upx;
		width: 90%;
		align-items: center;
		border-bottom: 1upx solid #DCDCDC;
		margin: 0 auto;
		.Class_avter{
			display: flex;
			width: 80upx;
			height: 80upx;
			border-radius: 40upx;
		}
	}
	.Class_title{
		display: flex;
		width: 80%;
		height: 60upx;
		font-size: 26upx;
		margin-top: -30upx;
		align-items: center;
		position: absolute;
		left: 20%;
	}
	.Class_details{
		display: flex;
		width: 80%;
		height: 40upx;
		margin-top: 30upx;
		font-size: 18upx;
		position: absolute;
		left: 20%;
		image{
			width: 30upx;
			height: 30upx;
		}
	}
	.Class_infochild:last-child,.Class_detailschild:last-child{
		margin-left: auto;
		padding-right: 20upx;
	}
	.Class_infochild,.Class_detailschild{
		padding-left: 2%;
	}
	.Class_detailschild:first-child{
		padding: 0;
	}
	
	/*底部关注畅聊按钮*/
	.FootButoon{
		display: flex;
		width: 100%;
		height: 60upx;
		position: fixed;
		left: 0;
		bottom: 14upx;
		color:#fff;
		font-size:26upx;
		view{
			width: 40%;
			height: 100%;
			background: #00BCBB;
			border-radius: 10upx;
			margin-left: 7%;
			text-align: center;
			line-height: 60upx;
		}
	}
	
	/*表格样式*/
	#panel{
	  width: 100%;
	  background:#fff;
	}
	
	#panel text{
		line-height: 9vh;
		border: 1px solid #00BCBB;
	}
	
	.flex-row{
	  display: flex;
	  flex-direction: row;
	  justify-content: center;
	}
	.flex-column{
	  display: flex;
	  flex-direction: column;
	  justify-content: center;
	  align-items: stretch;
	}
	
	.flex-cell{
	  flex: 1;
	}
</style>
